$(document).ready(function(){
    var eMsgContent = $('#msgContent');
    eMsgContent.on('click', '.okBtn', function(){
        var that = this;
        $.post('/user/ajaxokmsg.html', {'mid' : $(that).parent('li').data('mid')}, function(res){
            var data = JSON.parse(res);
            if(data.code == 200){
                $(that).parent('li').removeClass('msgMark');
                $(that).remove();
                clearpop('标记成功！');
            }else{
                clearpop('标记为已阅读操作出现错误，请刷新后再试！');
            }
        });
    });
    eMsgContent.on('click', 'li a', function(e){
        $.post('/user/ajaxokmsg.html', {'mid' : $(this).parent('li').data('mid')}, function(){});
    });
    eMsgContent.on('click', '.dlBtn', function(){
        if(confirm("您确认要删除这条记录么？")){
            var obj = $(this).parent('li');
            $.post('/user/ajaxdlmsg.html', {'mid' : obj.data('mid'), 'status' : obj.data('status')}, function(res){
                var data = JSON.parse(res);
                if(data.code == 200){
                    obj.remove();
                    clearpop('删除成功！');
                }else{
                    clearpop('删除这条记录出现错误，请刷新后再试！');
                }
            });
        }
    });
});